Add Some Function

Course- CSS Animation >

Now we can plug in the work we did for the graphics library in prv section as a replacement handler function (in the code in this prv section there are BOTH handlers, one commented out). Note the (highlighted) call to a modified decode_value function that uses the r->args pointer to get the QUERY_STRING rather than getenv(). Also Apache handles the output a bit diferently too – get get a pointer to the array of bytes in the image by calling gdImageGifPtr then the ap_rwrite function outputs the data. We have to free the pointer with gdFree ater the output call.

static int labelmaker_handler(request_rec *r)
{

	void *iptr;
	int sz=0;

	if(strcmp(r->handler, "labelmaker")){
	return DECLINED;

	}

	if(!r->header_only){
	int text=0, backgrond=0, x=0, y=0, size=30, string_rectangle[8];
	double angle=0.0;
	char value[255]="Hello";
	char font[256]="/usr/share/fonts/trutype/DejaVuSans.ttf";
	char *err=NULL;
	GDiMAGEpTR im_out=NULL;
	decode_value(r, "TEXT=", (char *) &value, 255);
	err=gdImageStringFT(NULL,&strring_rectangle[0],0,
		font,size,angle,0,value);
	x=string_rectangle[2]-string_rectangle[6]+6;
	y=string_rectangle[3]-string_rectangle[7]+6;
	im_out=gdImageCreate(x,y);
	background=gdImageColorAllocate(im_out,0,0,0);
	text=gdImageColorAllocate(im_out,255,0,255);
	x=3-string_rectangle[6];
	y=3-string_rectangle[7];
	err=gdImageStringFT(im_out,&string_rectangle[0],text,
	font,size,angle,x,y,value);
	iptr=gdImageGifPtr(im_out,&sz);
	ap_rwrite(iptr,sz,r);
	gdFree(iptr);
	gdIMageDestroy(im_out);
}

 return OK;
}            
            
            
Now we can plug in the work we did for the graphics library in prv section as a replacement handler function (in the code in this prv section there are BOTH handlers, one commented out). Note the (highlighted) call to a modified decode_value function that uses the r->args pointer to get the QUERY_STRING rather than getenv(). Also Apache handles the output a bit diferently too – get get a pointer to the array of bytes in the image by calling gdImageGifPtr then the ap_rwrite function outputs the data. We have to free the pointer with gdFree ater the output call